home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
controls
/
setfont.frm
< prev
next >
Wrap
Text File
|
1993-05-16
|
6KB
|
205 lines
VERSION 2.00
Begin Form Form1
Caption = "You, Too, Can Be an Optometrist"
ClientHeight = 2715
ClientLeft = 1185
ClientTop = 1770
ClientWidth = 7770
Height = 3120
Left = 1125
LinkTopic = "Form1"
ScaleHeight = 2715
ScaleWidth = 7770
Top = 1425
Width = 7890
Begin CommandButton cmdCount
Caption = "Control Count"
Height = 495
Left = 6000
TabIndex = 3
Top = 240
Width = 1455
End
Begin CommandButton cmdShrink
Caption = "Shrink"
Enabled = 0 'False
Height = 495
Left = 240
TabIndex = 2
Top = 1080
Width = 1215
End
Begin CommandButton cmdEnd
Caption = "End"
Height = 495
Left = 6240
TabIndex = 1
Top = 1080
Width = 1215
End
Begin CommandButton cmdEnlarge
Caption = "Enlarge"
Height = 495
Left = 240
TabIndex = 0
Top = 240
Width = 1215
End
Begin Label lblFive
BorderStyle = 1 'Fixed Single
Height = 255
Left = 3360
TabIndex = 8
Top = 2280
Width = 500
End
Begin Label lblFour
BorderStyle = 1 'Fixed Single
Height = 255
Left = 3360
TabIndex = 7
Top = 1680
Width = 500
End
Begin Label lblThree
BorderStyle = 1 'Fixed Single
Height = 255
Left = 3360
TabIndex = 6
Top = 1200
Width = 500
End
Begin Label lblTwo
BorderStyle = 1 'Fixed Single
Height = 255
Left = 3360
TabIndex = 5
Top = 600
Width = 500
End
Begin Label lblOne
BorderStyle = 1 'Fixed Single
Height = 255
Left = 3360
TabIndex = 4
Top = 120
Width = 500
End
End
Option Explicit
Dim MyFontSizes(6) As Single
Dim EyeStrings(5) As String
Dim CurrentFont As Integer
Sub cmdCount_Click ()
MsgBox "There are " & controls.Count & " controls on this form."
End Sub
Sub cmdEnd_Click ()
Unload form1
End Sub
Sub cmdEnlarge_Click ()
Dim i As Integer
CurrentFont = CurrentFont + 1
For i = 0 To controls.Count - 1
If TypeOf controls(i) Is Label Then
controls(i).FontSize = MyFontSizes(CurrentFont)
End If
Next i
PositionEyeBoxes
cmdShrink.Enabled = True
If CurrentFont = 6 Then
cmdEnlarge.Enabled = False
End If
End Sub
Sub cmdShrink_Click ()
Dim i As Integer
CurrentFont = CurrentFont - 1
For i = 0 To controls.Count - 1
If TypeOf controls(i) Is Label Then
controls(i).FontSize = MyFontSizes(CurrentFont)
End If
Next i
PositionEyeBoxes
If CurrentFont = 1 Then
cmdShrink.Enabled = False
End If
cmdEnlarge.Enabled = True
End Sub
Sub Form_Load ()
EyeStrings(1) = "E"
EyeStrings(2) = "F P"
EyeStrings(3) = "T O Z"
EyeStrings(4) = "L P E D"
EyeStrings(5) = "P E C F D"
lblOne.Caption = EyeStrings(1)
lblTwo.Caption = EyeStrings(2)
lblThree.Caption = EyeStrings(3)
lblFour.Caption = EyeStrings(4)
lblFive.Caption = EyeStrings(5)
MyFontSizes(1) = 8.25
MyFontSizes(2) = 9.75
MyFontSizes(3) = 12#
MyFontSizes(4) = 13.5
MyFontSizes(5) = 18
MyFontSizes(6) = 24
CurrentFont = 1
form1.FontSize = MyFontSizes(CurrentFont)
lblOne.Top = 200
PositionEyeBoxes
End Sub
Sub PositionEyeBoxes ()
Const DELTA = 200
Const INCREMENT = 100
Dim ThisLabel As Label
form1.FontSize = MyFontSizes(CurrentFont)
form1.Height = 5 * form1.TextHeight("TEST") + 1400
Set ThisLabel = lblOne
ThisLabel.Width = form1.TextWidth(EyeStrings(1)) + DELTA
ThisLabel.Height = form1.TextHeight(EyeStrings(1))
ThisLabel.Left = (form1.Width - ThisLabel.Width) / 2
Set ThisLabel = lblTwo
ThisLabel.Width = form1.TextWidth(EyeStrings(2)) + DELTA
ThisLabel.Height = form1.TextHeight(EyeStrings(2))
ThisLabel.Move (form1.Width - ThisLabel.Width) / 2, lblOne.Top + lblOne.Height + INCREMENT
Set ThisLabel = lblThree
ThisLabel.Width = form1.TextWidth(EyeStrings(3)) + DELTA
ThisLabel.Height = form1.TextHeight(EyeStrings(3))
ThisLabel.Move (form1.Width - ThisLabel.Width) / 2, lblTwo.Top + lblTwo.Height + INCREMENT
Set ThisLabel = lblFour
ThisLabel.Width = form1.TextWidth(EyeStrings(4)) + DELTA
ThisLabel.Height = form1.TextHeight(EyeStrings(4))
ThisLabel.Move (form1.Width - ThisLabel.Width) / 2, lblThree.Top + lblThree.Height + INCREMENT
Set ThisLabel = lblFive
ThisLabel.Width = form1.TextWidth(EyeStrings(5)) + DELTA
ThisLabel.Height = form1.TextHeight(EyeStrings(5))
ThisLabel.Move (form1.Width - ThisLabel.Width) / 2, lblFour.Top + lblFour.Height + INCREMENT
End Sub